{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. Bits, Data Types, and Operations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For today's class, we will work in small groups (two or three). One of you, open a blank notebook, and the others should close their laptops. We will trade-off typing as we go." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.1 Representing Signed Integers" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Three representations of signed integers:\n", "\n", "\n", "\n", "Q1: What is unusual about two of the columns? There is a number there that you don't usually see." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.2 Signed Magnitude" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Q2: What is 11111 + 01111 ?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.3 One's Complement" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Q3: What is 10000 + 01111 ?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.4 Two's Complement" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Q4: Work out by hand: What is 10001 + 01111 ?\n", "\n", "Q5: Work out by hand: What is the two's complement for -13?\n", "\n", "Q6: Work out by hand: What is the two's complement for -57 ?\n", "\n", "Q7: Using the LC-3, compute the following:\n", "\n", "* a: 8 + -7\n", "* b: 5 + 5\n", "* c: -5 + -5\n", "* d: -15 + 15\n", "* e: -8 + 1\n", "* f: -15 + -1\n", "* g: -16 + -1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.5 Binary to Decimal Conversion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "NOTE: All binary will be in two's complement.\n", "\n", "Q8: Work out by hand: convert 01000 to decimal\n", "\n", "Q9: Work out by hand: convert 11000 to decimal\n", "\n", "Q10: Work out by hand: convert 11111 to decimal\n", "\n", "Q11: Work out by hand: convert 111111111 to decimal\n", "\n", "Q12: Work out by hand: convert 000001000 to decimal" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.6 Decimal to Binary Conversion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Q13: Convert decimal 105 to binary\n", "\n", "Q14: Convert decimal -105 to binary\n", "\n", "Q15: convert decimal 99 to binary\n", "\n", "Q16: convert decimal -14 to binary" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.7 Additional Additions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Explore the patterns of adding any two numbers to itself. Try positive and negative numbers. \n", "\n", "Q17: Do you see a pattern? Describe it." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Logical Operations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two new instructions:\n", "\n", "Bitwise AND and NOT (16 bits each):\n", "\n", "```\n", "AND: 0101 DST SRC 1 VVVVV\n", "NOT: 1001 DST SRC 111111\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "where:\n", "\n", "* DST - destination register, in three bits\n", "* SRC - source register, in three bits\n", "* VVVVV - value to AND with source register contents\n", "\n", "Q18: Write out the truth tables for AND and NOT.\n", "\n", "Q19: Write out the truth tables for OR and XOR\n", "\n", "Q20: Try out the AND and NOT instructions on the LC-3. Do they work as described?" ] } ], "metadata": { "kernelspec": { "display_name": "Calysto LC3", "language": "asm", "name": "calysto_lc3" }, "language_info": { "file_extension": ".asm", "mimetype": "text/x-gas", "name": "gas" } }, "nbformat": 4, "nbformat_minor": 2 }